#ifndef _YL_NODE_UTILS_
#define _YL_NODE_UTILS_

namespace yoctolog_viewer
{
	// Gets a node's path based on its Name (the FullPath property bases it on the "Text" property of each node)
	static System::String ^GetNodePath(System::Windows::Forms::TreeNode ^pNode)
	{
		System::String ^strResult = "";
		if( pNode->Parent )
		{
			strResult += pNode->Parent->Name;
			strResult += "/";
		}
		strResult += pNode->Name;
		return strResult;
	}

	// Searches in a TreeNodeCollection for a specified key, and compares it to the Name of each node
	static System::Windows::Forms::TreeNode ^ FindNode(System::String ^strKey,
		TreeNodeCollection ^pTreeNodeCollectionToLookIn)
	{
		for (int i = 0; i < pTreeNodeCollectionToLookIn->Count; i++)
		{
			if (System::String::Compare(pTreeNodeCollectionToLookIn[i]->Name, strKey) == 0)
				return pTreeNodeCollectionToLookIn[i];
		}

		return nullptr;
	}

}

#endif